package org.example.day01;

public class MyThread3 extends Thread {
    @Override
    public void run() {
        super.run();
        for (int i = 0; i < 100000; i++) {
            System.out.println("i+=" + (i + 1));
        }
    }

    public static void main(String[] args) {
        try {
            MyThread3 myThread3 = new MyThread3();
            myThread3.start();
            Thread.sleep(1000);
            System.out.println("是否停止1？ = " + myThread3.isInterrupted()); //false
            myThread3.interrupt();
            System.out.println("是否停止2？ = " + myThread3.isInterrupted()); //true
            System.out.println("是否停止3？ = " + Thread.currentThread().isInterrupted()); //false
            Thread.currentThread().interrupt();
            System.out.println("是否停止4？ = " + Thread.currentThread().isInterrupted()); //true
        } catch (InterruptedException e) {
            System.out.println("main异常");
            e.printStackTrace();
        }
        System.out.println("end");
    }
}
